/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ifpb.pod.model;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

/**
 *
 * @author Diogenes
 */
@NamedQueries({
    @NamedQuery(name = "contato.buscar", query = "FROM Contato c WHERE login = ?1")})
@Entity
public class Contato implements Serializable, Comparable<Contato> {

    @Id
    @GeneratedValue
    private int id;
    private String login;

    public Contato() {
    }

    public Contato(String login) {
        this.login = login;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Contato other = (Contato) obj;
//        if (this.id != other.id) {
//            return false;
//        }
        if ((this.login == null) ? (other.login != null) : !this.login.equals(other.login)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
//        hash = 97 * hash + this.id;
        hash = 97 * hash + (this.login != null ? this.login.hashCode() : 0);
        return hash;
    }

    public int compareTo(Contato o) {
        int valor = login.compareTo(o.login);
        return (valor != 0 ? valor : 1);
    }

    @Override
    public String toString() {
        return "@"+this.login;
    }


}
